<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<script>
	var a = [
		{
			"UUID": "1d2a52b28bf3db39",
			"Parent": "",
			"CnName": "行政",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52b4a6fc7a00",
			"Parent": "",
			"CnName": "运营",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52b7c9394a2d",
			"Parent": "",
			"CnName": "销售",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52bcf2ce5220",
			"Parent": "",
			"CnName": "教研",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52bd07299108",
			"Parent": "",
			"CnName": "客服",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52bd76af48c5",
			"Parent": "",
			"CnName": "市场",
			"Status": "1",
			"Children": [
				{
					"UUID": "1d2a6b412c02841f",
					"Parent": "1d2a52bd76af48c5",
					"CnName": "职能",
					"Status": "1",
					"Children": []
				},
				{
					"UUID": "1d2a6b44bb56dd69",
					"Parent": "1d2a52bd76af48c5",
					"CnName": "TMK",
					"Status": "1",
					"Children": [
						{
							"UUID": "1d2a7nvde92b9663",
							"Parent": "1d2a6b44bb56dd69",
							"CnName": "阿朵发送",
							"Status": "1",
							"Children": []
						},
						{
							"UUID": "1d2a7nve3949e2d6",
							"Parent": "1d2a6b44bb56dd69",
							"CnName": "发送方",
							"Status": "1",
							"Children": []
						}
					]
				},
				{
					"UUID": "1d2a7r467cf20b8d",
					"Parent": "1d2a52bd76af48c5",
					"CnName": "但法国大使馆",
					"Status": "1",
					"Children": []
				}
			]
		},
		{
			"UUID": "1d2acqm1181dc23a",
			"Parent": "",
			"CnName": "gsdfg",
			"Status": "1",
			"Children": []
		}
	];
	var Data = [
		{
			"UUID": "1d2a52b28bf3db39",
			"Parent": "",
			"CnName": "行政",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52b4a6fc7a00",
			"Parent": "",
			"CnName": "运营",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52b7c9394a2d",
			"Parent": "",
			"CnName": "销售",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52bcf2ce5220",
			"Parent": "",
			"CnName": "教研",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52bd07299108",
			"Parent": "",
			"CnName": "客服",
			"Status": "1",
			"Children": []
		},
		{
			"UUID": "1d2a52bd76af48c5",
			"Parent": "",
			"CnName": "市场",
			"Status": "1",
			"Children": [
				{
					"UUID": "1d2a6b412c02841f",
					"Parent": "1d2a52bd76af48c5",
					"CnName": "职能",
					"Status": "1",
					"Children": []
				},
				{
					"UUID": "1d2a6b44bb56dd69",
					"Parent": "1d2a52bd76af48c5",
					"CnName": "TMK",
					"Status": "1",
					"Children": [
						{
							"UUID": "1d2a7nvde92b9663",
							"Parent": "1d2a6b44bb56dd69",
							"CnName": "阿朵发送",
							"Status": "1",
							"Children": []
						},
						{
							"UUID": "1d2a7nve3949e2d6",
							"Parent": "1d2a6b44bb56dd69",
							"CnName": "发送方",
							"Status": "1",
							"Children": []
						}
					]
				},
				{
					"UUID": "1d2a7r467cf20b8d",
					"Parent": "1d2a52bd76af48c5",
					"CnName": "但法国大使馆",
					"Status": "1",
					"Children": []
				}
			]
		},
		{
			"UUID": "1d2acqm1181dc23a",
			"Parent": "",
			"CnName": "gsdfg",
			"Status": "1",
			"Children": []
		}
	];

	var Marks = function(n){
		var str = "";
		for(var i=0;i<n;i++){
			str = str + " |---- ";
		}
		return str;
	};
	function AddLevel(array,Level = 0){
		for(var key in array){
			array[key].Level = Level;
			array[key].CnName = Marks(array[key].Level)+array[key].CnName;
			if(0 != Object.keys(array[key].Children).length){
				AddLevel(array[key].Children,Level + 1);
			}
		}
		return array;
	}
	console.log(AddLevel(a));



	var API = JSON.parse('<{$TagsJSON}>'.replace(/&quot;/g, '"'));
	var Marks = function(n){
		var str = "";
		for(var i=0;i<n;i++){
			str = str + " |---- ";
		}
		return str;
	};

	function AddLevel(array,Level = 0,sum = 0,aa = []){
		for(var key in array){
			array[key].Level = Level;
			array[key].CnName = Marks(array[key].Level)+array[key].CnName;
			sum = sum +1;
			aa[sum] = array[key];
			if(0 != Object.keys(array[key].Children).length){
				AddLevel(array[key].Children,Level + 1,sum,aa);
			}
		}
		return aa;
	}
	var TagsData = AddLevel(API);
	console.log("ceshi"+TagsData);

</script>
</body>
</html>